﻿<ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:Controls.Common="clr-namespace:Imagin.Controls.Common;assembly=Imagin.Controls.Common"
    xmlns:Controls.Common.Converters="clr-namespace:Imagin.Controls.Common.Converters;assembly=Imagin.Controls.Common">
    <Controls.Common.Converters:CenterToolTipConverter x:Key="CenterToolTipConverter"/>

    <Style TargetType="{x:Type ToolTip}">
        <Setter Property="Background" Value="{DynamicResource Brush.ToolTip.Background}" />
        <Setter Property="BorderBrush" Value="{DynamicResource Brush.ToolTip.Border}" />
        <Setter Property="Border.CornerRadius" Value="2" />
        <Setter Property="Foreground" Value="{DynamicResource Brush.ToolTip.Foreground}" />
        <Setter Property="HorizontalAlignment" Value="Left" />
        <Setter Property="MaxWidth" Value="425" />
        <Setter Property="Opacity" Value="0.95" />
        <Setter Property="Padding" Value="15,7" />
        <Setter Property="Placement" Value="Bottom" />
        <Setter Property="HorizontalOffset">
            <Setter.Value>
                <MultiBinding Converter="{StaticResource CenterToolTipConverter}">
                    <Binding RelativeSource="{RelativeSource Self}" Path="PlacementTarget.ActualWidth"/>
                    <Binding RelativeSource="{RelativeSource Self}" Path="ActualWidth"/>
                </MultiBinding>
            </Setter.Value>
        </Setter>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="ToolTip">
                    <Grid>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="*"/>
                        </Grid.RowDefinitions>
                        <Border 
                            Grid.Row="1"
                            CornerRadius="{TemplateBinding Border.CornerRadius}" 
                            BorderThickness="{TemplateBinding BorderThickness}" 
                            Background="{TemplateBinding Background}" 
                            Padding="{TemplateBinding Padding}" 
                            Margin="{TemplateBinding Margin}" 
                            Opacity="{TemplateBinding Opacity}">
                            <Border.Effect>
                                <DropShadowEffect Color="{DynamicResource DropShadowColor}" Opacity="0.25" BlurRadius="15" ShadowDepth="3"/>
                            </Border.Effect>
                            <TextBlock 
                                Foreground="{TemplateBinding Foreground}"
                                HorizontalAlignment="{TemplateBinding HorizontalAlignment}"
                                Text="{TemplateBinding Content}"
                                TextTrimming="CharacterEllipsis"
                                TextWrapping="Wrap">
                            </TextBlock>
                        </Border>
                        <Controls.Common:MaskedImage 
                            ImageColor="{TemplateBinding Background}" 
                            Source="pack://application:,,,/Imagin.Styles;component/Images/Triangle.png" 
                            HorizontalAlignment="Center" 
                            Margin="0,0,0,-5"
                            Padding="0"/>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
</ResourceDictionary>